package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Order;
import com.itheima.reggie.service.OrderService;
import com.itheima.reggie.service.impl.OderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.locks.ReentrantReadWriteLock;

@RestController
@RequestMapping("/order")
public class orderController {

    @Autowired
    private OrderService orderService;


    @GetMapping("userPage")
    public ResultInfo finfByPage(@RequestParam(name = "page")Integer pageNumber,
                                 @RequestParam(name = "pageSize")Integer pageSize){
        Page<Order> byPage = orderService.findByPage(pageNumber, pageSize);
        return ResultInfo.success(byPage);
    }




    @PostMapping("submit")
    public ResultInfo submit(@RequestBody Order order) {

        orderService.save(order);
        return ResultInfo.success(null);
    }

}
